const app = getApp();
const $api = require('../../utils/api.js').API;
const { $Toast } = require('../../dist/base/index');
Page({
    data: {
        complainType: '1',
        complainText: '',
        order_id: ''
    },

    onLoad(e) {
        console.log('complain onload')
        this.setData({
            order_id: e.order_id
        })
    },

    // 更换类型选择
    onChange(event) {
        this.setData({
            complainType: event.detail,
        });
        console.log(this.data.complainType)
    },

    // 输入投诉内容
    onInput(e) {
        // console.log(e.detail.value)
        this.setData({
            complainText: e.detail.value
        })
    },

    // 提交投诉
    admit() {
        let params = {
            type: parseInt(this.data.complainType),
            text: this.data.complainText,
            openid: app.globalData.openid,
            order_id: this.data.order_id
        }
        // console.log(params)
        $api.addComplain(params).then(res => {
            $Toast({
                content: '发布成功',
                type: 'success',
                duration: 2000
            });
        })
    }

})